package com.gome.ocean.common.enums;

/**
 * 分库分表算法
 * 
 * @author haqiaolong 2016年4月7日 上午11:27:28
 * @since 5.0.0
 */
public enum ShardAlgorithm {

    HASH(0), MODULE(1);

    private int value;

    private ShardAlgorithm(int value){
        this.value = value;
    }

    public static ShardAlgorithm shardAlgorithm(int value) {
        for (ShardAlgorithm shardAlgorithm : ShardAlgorithm.values()) {
            if (shardAlgorithm.getValue() == value) {
                return shardAlgorithm;
            }
        }
        return null;
    }

    public int getValue() {
        return value;
    }

    public static String getString(ShardAlgorithm shardAlgorithm) {
        switch (shardAlgorithm) {
            case HASH:
                return "HASH绝对值";
            case MODULE:
                return "取模算法";
        }
        return null;
    }
}
